<?php 

require_once('getconfig.php');

Class Model_fixedcode extends Dbo_DbManager
 {

	protected $charFixedcode;
	protected $charCodedesc;

	protected $numberProductid;
	protected $charProductdesc;
	protected $numberProductPrice;

 	public function __construct($bolCon=TRUE) {
		parent::__construct($bolCon);
	}
	
	public function getFixedcode()
	{
		return  $this->charFixedcode;
	}
	public function getCodedesc()
	{
		return  $this->charCodedesc;
	}
	
//product details reading
	public function getProductid()
	{
		return  $this->numberProductid;
	}	
	public function getProductdesc()
	{
		return  $this->charProductdesc;
	}	
	public function getProductPrice()
	{
		return  $this->numberProductPrice;
	}					


	public function setFixedcode($charFixedcode)
	{
		$this->charFixedcode=$charFixedcode;
	}
 	public function setCodedesc($charCodedesc)
	{
		$this->charCodedesc=$charCodedesc;
	}
//product seting	
 	public function setProductid($numberProductid)
	{
		$this->numberProductid=$numberProductid;
	}
 	public function setProductdesc($charProductdesc)
	{
		$this->charProductdesc=$charProductdesc;
	}
 	public function setProductprice($numberProductPrice)
	{
		$this->numberProductPrice=$numberProductPrice;
	}			


	public function write()
	{
		$objDbManager = new Dbo_DbManager();
		return $objDbManager->write($this,FALSE);
	}


	public static function delete($intproductid)
	{
		$objDbManager = new Dbo_DbManager();
		return $objDbManager->remove($intproductid,__CLASS__);
	}

	public static function build(array $arrModel_fixedcode)
	{
		$objModel_fixedcode = new Model_fixedcode(FALSE);
		@$objModel_fixedcode->setFixedcode($arrModel_fixedcode['c_code']);
		@$objModel_fixedcode->setCodedesc($arrModel_fixedcode['c_code_desc']);
		return $objModel_fixedcode;
 	 }
	 
	public static function build_product(array $arrModel_fixedcode)
	{
		$objModel_fixedcode = new Model_fixedcode(FALSE);
		@$objModel_fixedcode->setProductid($arrModel_fixedcode['PN_PRDCT_ID']);
		@$objModel_fixedcode->setProductdesc($arrModel_fixedcode['C_PRDCT_DESC']);
		@$objModel_fixedcode->setProductprice($arrModel_fixedcode['N_PRIZE']);
		return $objModel_fixedcode;
 	 }	 
 	 
    
     public static function get_Fixedcode($charcodetype){
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from fixedcode where c_code_type='$charcodetype'";
		//echo $qry;
		$arrModel_User=$objDbManager->runquery("$qry");
		if (count( $arrModel_User ) > 0) {
			foreach ( $arrModel_User as $arrNew ) {
				$objUser = self::build ( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}
	
	 public static function get_Fixedcode_desc($code){
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from fixedcode where c_code='$code'";
		//echo $qry;
		$arrModel_User=$objDbManager->runquery("$qry");
		if (count( $arrModel_User ) > 0) {
			foreach ( $arrModel_User as $arrNew ) {
				$objUser = self::build ( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}
	
     public static function get_Fixedcodesc($code,$charcodetype){

		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from fixedcode where c_code_type='$charcodetype' and c_code='$code' ";
		//echo $qry;
		$arrModel_User=$objDbManager->runquery("$qry");
		if (count( $arrModel_User ) > 0) {
			foreach ( $arrModel_User as $arrNew ) {
				$objUser = self::build ( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	
 	 
     public static function get_Productmaster(){
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from PRODUCT_MASTER where C_STATUS='Y' ";
		echo $qry;
		$arrModel_User=$objDbManager->runquery("$qry");
		if (count( $arrModel_User ) > 0) {
			foreach ( $arrModel_User as $arrNew ) {
				$objUser = self::build_product ( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	 
 	 


 }
 ?>